package com.young.springdemo.utils.domain;

import lombok.Data;

/**
 * @program: springdemo
 * @description 返回结果统一处理类
 * @author: Young
 * @create: 2020-05-29 15:10
 **/
@Data
public class Result<T> {
    private String errorcode;
    private String status;
    private T data;

    public Result() {
    }

    public Result(T data) {
        this.status = "200";
        this.errorcode = "成功";
        this.data = data;
    }
    public Result(CodeMsg codeMsg) {
        if (codeMsg == null)return;
        this.status = codeMsg.getStatus();
        this.errorcode = codeMsg.getErrorcode();
    }

    public static <T> Result<T> success(T data){
        return new Result<>(data);
    }
    public static <T> Result<T> success(){
        return ((Result<T>) success(""));
    }
    public static <T> Result<T> error(CodeMsg cm){
        return new Result<>(cm);
    }

}
